import java.util.Scanner;
import java.util.TreeSet;

public class Test01 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        String a[] = s.split("；");
        String c[];
        TreeSet<Book> ts = new TreeSet<Book>();
        int sum = 0;
        for (String b : a){
            c = b.split("：");
            Book book = new Book(c[0],Integer.parseInt(c[1]));
            sum += Integer.parseInt(c[1]);

            ts.add(book);
        }
        for (Book book : ts){
            System.out.println(book);
        }
        System.out.println("总价格为:"+ sum);
    }
}
class Book implements Comparable{
    String name;
    int price;
    public Book(String name,int price){
        this.name = name;
        this.price = price;
    }
    public int compareTo(Object o){
        Book b = (Book)o;
        return this.price - b.price;
    }

    public String toString(){
        return name+"："+price;
    }
}

//实例  Java程序设计：34；Web程序设计：56；JSP程序设计：20